home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvtools / examples / windows / mfc_mdi / mfc_mdidoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-08  |  3.3 KB  |  128 lines

  1. // mfc_mdiDoc.cpp : implementation of the CMfc_mdiDoc class
  2. //
  3.  
  4. /////////////////////////////////////////////////////////////////////////////
  5. //
  6. //    DataViews Multiple Document Inteface (MDI) example program.
  7. //
  8. //    CMfc_mdiDoc class
  9. //    -----------------
  10. //
  11. //    The simplest way to imagine integrating DataViews into the MFC Document-
  12. //    View architecture is to first think of the DataViews view file as really
  13. //    belonging the CDocument (and with that, an unfortunate clash of nomencla-
  14. //    ture!), and the DataView's screen and drawport as belonging more naturally
  15. //    with the MFC CView.
  16. //
  17. //    With that as a starting point then, CMfc_mdiDoc is responsible for the
  18. //    creation (TviLoad) and destruction (TviDestroy) of DataViews views, filling
  19. //    requests for the view from the MFC CView object (GetDVview, done as an
  20. //    inline in the .h file), and finally, for notifying the CView that a Data-
  21. //    Views view file has been succesfully loaded for it to display.
  22. //
  23. /////////////////////////////////////////////////////////////////////////////
  24.  
  25.  
  26. #include "stdafx.h"
  27. #include "mfc_mdi.h"
  28.  
  29. #include "mfc_mdiDoc.h"
  30. #include "mfc_mdiView.h"
  31.  
  32. #ifdef _DEBUG
  33. #define new DEBUG_NEW
  34. #undef THIS_FILE
  35. static char THIS_FILE[] = __FILE__;
  36. #endif
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CMfc_mdiDoc
  40.  
  41. IMPLEMENT_DYNCREATE(CMfc_mdiDoc, CDocument)
  42.  
  43. BEGIN_MESSAGE_MAP(CMfc_mdiDoc, CDocument)
  44.     //{{AFX_MSG_MAP(CMfc_mdiDoc)
  45.         // NOTE - the ClassWizard will add and remove mapping macros here.
  46.         //    DO NOT EDIT what you see in these blocks of generated code!
  47.     //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CMfc_mdiDoc construction/destruction
  52.  
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. //
  56. CMfc_mdiDoc::CMfc_mdiDoc()
  57. : m_DVview(0)
  58. {
  59. }
  60.  
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. //
  64. // Destroy the DataViews view...
  65. //
  66. CMfc_mdiDoc::~CMfc_mdiDoc()
  67. {
  68.     if(m_DVview)
  69.         TviDestroy(m_DVview);
  70. }
  71.  
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CMfc_mdiDoc serialization
  75.  
  76. void CMfc_mdiDoc::Serialize(CArchive& ar)
  77. {
  78.     if (ar.IsStoring())
  79.     {
  80.         // TODO: add storing code here
  81.     }
  82.     else
  83.     {
  84.         // TODO: add loading code here
  85.     }
  86. }
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CMfc_mdiDoc diagnostics
  90.  
  91. #ifdef _DEBUG
  92. void CMfc_mdiDoc::AssertValid() const
  93. {
  94.     CDocument::AssertValid();
  95. }
  96.  
  97. void CMfc_mdiDoc::Dump(CDumpContext& dc) const
  98. {
  99.     CDocument::Dump(dc);
  100. }
  101. #endif //_DEBUG
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CMfc_mdiDoc commands
  105.  
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108. //
  109. //    OnOpenDocument
  110. //
  111. BOOL CMfc_mdiDoc::OnOpenDocument(LPCTSTR lpszPathName) 
  112. {
  113.     //
  114.     // Load from disk the DataViews view file...
  115.     //
  116.     if((m_DVview = TviLoad((char*)lpszPathName)))
  117.     {
  118.         // ...and then getting the CView associated with this document...
  119.         POSITION pos = GetFirstViewPosition();
  120.         CMfc_mdiView* pView = (CMfc_mdiView*)GetNextView(pos);
  121.         ASSERT(pView);
  122.  
  123.         // ...and then finally telling it to display the DataViews view.
  124.         return pView->InitDv(m_DVview);
  125.     }
  126.     return FALSE;
  127. }
  128.